//
//  LoginViewController.m
//  FourthProject
//
//  Created by mac on 16/6/2.
//  Copyright © 2016年 cry. All rights reserved.
//

#import "LoginViewController.h"
#import "LoginTableViewCell.h"

@interface LoginViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray          *_dataArray;
    
    
    
    
}
@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    
    
    
    [self.myTable registerNib:[UINib nibWithNibName:@"LoginTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"cell"];
    
    
}

- (void)getData {
    
    NSArray *arr1 = @[@"订单",@"折扣",@"优惠券"];
    NSArray *arr2 = @[@"订单",@"折扣",@"优惠券"];
    NSArray *arr3 = @[@"订单",@"折扣",@"优惠券",@"优惠券"];
    
    _dataArray = [NSMutableArray arrayWithArray:@[arr1,arr2,arr3]];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 30)];
    return footerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 30;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 200)];
        
        UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 150)];
        bgView.image = [UIImage imageNamed:@"map"];
        [headerView addSubview:bgView];
        
        UIImageView *headV = [[UIImageView alloc] initWithFrame:CGRectMake(headerView.center.x, 40, 60, 60)];
        headV.layer.cornerRadius = 30;
        headV.clipsToBounds = YES;
        headV.image = [UIImage imageNamed:@"avatar_default.png"];
        [headerView addSubview:headV];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(headerView.center.x, 105, 160, 35)];
        label.text = @"点击登入,更多精彩";
        label.font = [UIFont systemFontOfSize:15];
        [headerView addSubview:label];
        
        float w = (WIDTH - 80) / 3;
        for (int i = 0; i < 3; i++) {
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake(20 + (w + 20) * i, 155, w, 40);
            [button setTitle:[NSString stringWithFormat:@"%d",i] forState:UIControlStateNormal];
            [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
            button.tag = 10 + i;
            [headerView addSubview:button];
            
        }
        return headerView;

    }else {
        return nil;
    }
  
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 200;
    }else {
        return 0;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    }else if (section == 1) {
        return 3;
    }else if (section == 2) {
        return 3;
    }else {
        return 4;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LoginTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.loginCellLabel.text = _dataArray[indexPath.section][indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"181818");
    
    
    
}











- (IBAction)backButtonClick:(id)sender {

    [self.navigationController popToRootViewControllerAnimated:YES];

}










@end
